<template>
  <div>
    <el-row
        style="width: 1300px;
        margin: 0px auto;
        border-radius: 10px;
        margin-bottom: 20px;
        box-shadow: 0 4px 8px 0 rgba(0 ,0 ,0 , 0.2), 0 6px 20px 0 rgba(0 ,0 ,0 ,0.2);">
      <el-col :span="6">
        <div class="grid-content bg-purple left-img">
          <router-link to='/'>
            <img src="http://lixinghe.meimeng.eu.org/flower/image/logo%E9%80%8F%E6%98%8E.png" style="width: 240px;height:120px;" alt="">
          </router-link>
        </div>
      </el-col>
      <el-col :span="12" v-if="router.currentRoute.value.meta.show">
        <div class="grid-content bg-purple-light">
          <div class="search-box">
            <!--搜索框-->
            <div class="search-box-group">
                <span class="el-icon-search"></span>
                <input type="text" placeholder="商品搜索" v-model.trim="keyword" @keyup.enter="goTo('searchgoods',{likes:keyword})">
                <button @click="goTo('search')" >搜索</button>
            </div>
            <!--搜索框下的文字-->
            <ul>
              <li @click="goTo('search')" v-for="(item,index) in hotSearchWord" :key="index">
                {{item}}
              </li>
            </ul>
          </div>
        </div>
      </el-col>
      <el-col :span="6" v-if="router.currentRoute.value.meta.right">
        <div class="grid-content bg-purple right">
          <div class="info">
            <el-icon size="30px" color="#F29BA5"><Iphone /></el-icon>
            <p>17612341234</p>
            <el-icon size="30px" color="#F29BA5"><Headset /></el-icon>
            <p>在线服务</p>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {reactive, toRefs} from "vue";
import router from "@/router";

  export default {
    name: "Home",
    setup(){
      let data = reactive({
        keyword:'',
        hotSearchWord:[
            '红玫瑰',
            '满天星',
            '小雏菊',
            '康乃馨',
            '向日葵'
        ]
      })

      //进行路由跳转
      function goTo(item){
        console.log('获得的路由的参数是',item);
        router.push(item)
      }

      return {
        ...toRefs(data),
        goTo,
        router
      }
    }
  }
</script>

<style scoped lang="scss">
  .el-row {

  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: white;
  }
  .grid-content {
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
  .logo {
    border: 1px solid greenyellow;
  }
  /*搜索框的样式*/
  .search-box {
    height: 70px;
    width: 500px;
    margin:0 auto;
    padding-top: 35px;
    .search-box-group {
      border: 2px solid #F29BA5;
      height: 40px;
      border-radius: 20px;
      width: 100%;
      span {
        color: #C0C4CC;
        display: inline-block;
        line-height: 40px;
        float: left;
        width: 54px;
        height: 40px;
      }
      input {
        height: 37px;
        border: 0px;
        float: left;
        width: 320px;
        outline: none;
        caret-color:#F29BA5;
      }
      input::-webkit-input-placeholder{
        color: #C0C4CC;
      }
      button {
        height: 41px;
        border: 1px solid #F29BA5;
        font-size: 20px;
        cursor: pointer;
        color: #FFFFFF;
        background: #F29BA5;
        float: right;
        border-radius: 17px;
        width: 120px;
      }
    }
  }

  /*改变placeholder的样式*/
  ul {
    margin: 0;
    height: 25px;
    padding-left: 58px;
  }
  li {
    list-style-type: none;
    float: left;
    line-height: 25px;
    font-size: 12px;
    color: #C0C4CC;
    margin-right: 20px;
    cursor: pointer;
    &:hover {
      color: #F29BA5;
    }
  }
  p {
    display: inline-block;
    margin: 15px;
    color: #C0C4CC;
    font-size: 18px;
  }
  .info {
    height: 60px;
    margin-top: 28px;
    text-align: left;
    display: flex;
    align-items: center;
    span{
      color: #F29BA5;
      margin-left: 10px;
      font-size:22px;
    }
    p:nth-of-type(2){
      cursor: pointer;
      &:hover {
        color: orange;
      }
    }
  }
  .left-img {
    margin-left: 80px;
  }
</style>
